{% extends 'home.html' %}

{% block content %}
<div class="row">
    <div class="panel panel-primary">
        <div class="panel-heading">退回</div>
        <div class="panel-body">
            <table class="table table-condensed">
                <thead>
                    <tr>
                        <th>证书编号</th>
                        <th>校准日期</th>
                        <th>序列号</th>
                        <th>客户</th>
                        <th>仪器型号</th>
                        <th>用户</th>
                        <th>查看</th>
                        <th>备注</th>
                    </tr>
                </thead>
                <tbody>

                    {% for item in reject_obj %}
                    <tr>
                        <td id="type">{{ item.c_number }}</td>
                        <td>{{ item.date }}</td>
                        <td>{{ item.snr }}</td>
                        <td>{{ item.all_data.A1PH_Zsdw53 }}</td>
                        <td>{{ item.all_data.A1PH_ProdModel03 }}</td>
                        <td>{{ item.user }}</td>
                        <td>
                            <a class="btn btn-primary btn-xs" href="/list/{{ item.type }}/{{ item.id }}/reject/"
                                id="view">查看</a>
                        </td>


                        <td>{{ item.comments }}</td>

                    </tr>
                    {% endfor %}

                </tbody>

            </table>

        </div>
    </div>
    <div class="panel panel-primary">
        <div class="panel-heading">未审批</div>
        <div class="panel-body">
            <table class="table table-condensed" data-toggle="table">
                <thead>
                    <tr>
                        <th>证书编号</th>
                        <th>校准日期</th>
                        <th>序列号</th>
                        <th>客户</th>
                        <th>仪器型号</th>
                        <th>查看</th>
                        <th>状态</th>
                    </tr>
                </thead>
                <tbody>

                    {% for item in user_submitted_data %}
                    <tr>
                        <td id="type">{{ item.all_data.A1PH_Received02 }}</td>
                        <td>{{ item.date }}</td>
                        <td>{{ item.all_data.A1PH_SN04 }}</td>
                        <td>{{ item.all_data.A1PH_Zsdw53 }}</td>
                        <td>{{ item.all_data.A1PH_ProdModel03 }}</td>

                        <td>
                            <a class="btn btn-primary btn-xs" href="/list/{{ item.type }}/{{ item.id }}/view/"
                                id="view">查看</a>
                        </td>

                        <td>
                            {{ item.get_approve_display }}
                        </td>

                    </tr>
                    {% endfor %}

                </tbody>
            </table>
            <ul class="pagination pagination-sm">
                {{ page_string|safe }}
            </ul>

        </div>
    </div>

</div>

{% endblock %}

{% block js %}
<script type="text/javaScript">
        function doExport() {
            $('#table').tableExport({
                    type: 'excel'
                }
            );
        }

        function jumpToPage() {
            var pageInput = document.querySelector('.page-input');
            var pageNumber = parseInt(pageInput.value);
            if (!isNaN(pageNumber) && pageNumber > 0) {
                window.location.href = '?page=' + pageNumber;
            } else {
                alert('请输入有效的页码');
            }
        }
    </script>
<script>
    var $table = $("#table");
    $(function () {
        $("#toolbar")
            .find("select")
            .change(function () {
                $table.bootstrapTable("destroy").bootstrapTable({
                    exportDataType: $(this).val(),
                    exportTypes: ["json", "xml", "csv", "txt", "sql", "excel", "pdf"],
                    columns: [
                        {
                            field: "state",
                            checkbox: true,
                            visible: $(this).val() === "selected",
                        },
                    ],
                });
            })
            .trigger("change");
    });
</script>

<script>
    $(function () {
        $('#syn').click(function () {
            $.ajax({
                url: '/list/{{ item.type }}/{{ item.id }}/syn/',
                type: 'POST',
                dataType: 'JSON',
                success: function (res) {
                    if (res.success) {
                        location.href = 'http://127.0.0.1:8000/list/';
                        alert('chenggong');
                    } else {
                        alert('创建失败');
                    }
                }
            })
        })
    })
</script>
{% endblock %}